<!-- 基本服务管理 -->
<template>
  <el-card>
    <el-row>
      <el-form ref="form" :model="searchDto" inline label-suffix=":">
        <el-form-item label="关键字" prop="serviceName">
          <el-input
            v-model="searchDto.serviceName"
            placeholder="请输入服务名称"
            style="width:250px"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" type="primary" @click="search">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-s-open" type="primary" @click="clear">重置</el-button>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-plus" type="primary" @click="addAppliance">新建基本服务</el-button>
        </el-form-item>
      </el-form>
    </el-row>

    <page-table
      ref="recovery"
      :page-data="pageData"
      :loading="loading"
      :do-get-page-data="getPageData"
    >
      <el-table-column type="index" label="编号" width="80" align="center" />
      <el-table-column prop="serviceName" label="基本服务名称" align="center" />
      <el-table-column prop="serviceDescription" label="基本服务描述" align="center" />
      <el-table-column prop="createTime" label="创建时间" align="center" />
      <el-table-column label="操作" align="center" width="300" fixed="right">
        <template slot-scope="scope">
          <el-tooltip content="编辑" placement="top">
            <el-button
              type="button"
              size="mini"
              icon="el-icon-edit"
              @click="editAppliance(scope.row)"
            >
            </el-button>
          </el-tooltip>
          <!--          <el-tooltip content="详情" placement="top">-->
          <!--            <el-button-->
          <!--              type="button"-->
          <!--              size="mini"-->
          <!--              icon="el-icon-view"-->
          <!--              @click="viewDetail(scope.row)"-->
          <!--            >-->
          <!--            </el-button>-->
          <!--          </el-tooltip>-->
          <el-tooltip content="删除" placement="top">
            <el-button
              type="button"
              size="mini"
              icon="el-icon-delete"
              @click="delAppliance(scope.row)"
            >
            </el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </page-table>
  </el-card>
</template>
<script>

export default {
  name: "ServiceManage",
  data() {
    return {
      pageData: {},
      loading: false,
      searchDto: {
        serviceName: null
      }
    }
  },
  methods: {
    // 获取分页数据`
    getPageData(val) {
      let tem = Object.assign(this.searchDto, val);
      this.API.getAssistBasicServicePageList(tem).then(ret => {
        this.pageData = ret.data;
      });
    },

    // 查询
    search() {
      this.getPageData();
    },

    //清空
    clear() {
      this.$refs.form.resetFields()
      this.getPageData();
    },

    editAppliance({ id: id }) {

      this.$router.push({ name: 'serviceManageDetail', query: { id } })
    },

    // 新增基本服务
    addAppliance() {
      this.$router.push({ name: 'serviceManageDetail' })
    },

    // 删除
    delAppliance({ id: id }) {
      this.$confirm("确认删除此基本服务?", "提示", { type: "warning" }).then(() => {
        this.API.deleteAssistBasicServiceById({ id }).then(ret => {
          this.success("删除成功!");
          this.getPageData();
        }).catch(err => {
          this.warning(err)
        });
      });
    }
  },
  mounted() {
    this.getPageData();
  }
};
</script>

<style scoped lang="scss"></style>
